package com.vcoud.mundialbrasil2014.adapter;

import java.util.ArrayList;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.vcoud.mbrasil2014.R;
import com.vcoud.mundialbrasil2014.model.PrincipalItem;

public class PrincipalListAdapter extends BaseAdapter {

	private Context context;
	private ArrayList<PrincipalItem> navDrawerItems;

	public PrincipalListAdapter(Context context,
			ArrayList<PrincipalItem> navDrawerItems) {
		this.context = context;
		this.navDrawerItems = navDrawerItems;
	}

	@Override
	public int getCount() {
		return navDrawerItems.size();
	}

	@Override
	public Object getItem(int position) {
		return navDrawerItems.get(position);
	}

	@Override
	public long getItemId(int position) {
		return position;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		if (convertView == null) {
			LayoutInflater mInflater = (LayoutInflater) context
					.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
			convertView = mInflater.inflate(R.layout.list_principal_item, null);
		}

		TextView txtTitle = (TextView) convertView.findViewById(R.id.nombre);

		txtTitle.setText(navDrawerItems.get(position).getTitle());
		convertView.setBackgroundResource(navDrawerItems.get(position)
				.getIcon());
		// displaying count
		// check whether it set visible or not

		return convertView;
	}
}